#!/usr/bin/python
# -*- coding: UTF-8 -*-

import os, shutil


source_path = 'H:\\HP\\'
save_path = 'D:\\Scanfile\\'

def createfolder(num='2019-0'):
    folder_path = save_path + num
    if not os.path.exists(folder_path):
        os.mkdir(folder_path)
    else :
        pass

def savefile(num='2019-0'):
    source_list = os.listdir(source_path)
    i = 0
    if not os.path.exists(save_path + num):
        os.mkdir(save_path + num)
    for name in source_list :
        srcfile_path = os.path.join(source_path, name)
        savefile_path = os.path.join(save_path + num, num + '-' + str(i) + '.jpg')
        #print(srcfile_path)
        #print(savefile_path)
        shutil.copyfile(srcfile_path, savefile_path)
        i = i + 1

def getfile(num = '2019-0'):
    #print("getfile",num)
    filelist = []
    file_path = save_path + num + '\\'
    #print(file_path)
    if os.path.exists(file_path):
        file_list = os.listdir(file_path)
        #print(file_list)
        for name in file_list:
            filelist.append(file_path + name)
        #print(filelist)
        return filelist
    else :
        return False

def getfilepath(num = '2019-0'):
    file_path = save_path + num + '\\'
    if os.path.exists(file_path):
        return file_path
    else:
        return False






